package StudyCode.summary.BufferAndChannel;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class AppendingByteBufferFile {
	public static void main(String[] args) {
		ByteBuffer bbuf = ByteBuffer.wrap("test".getBytes());
		File file = new File("E:/Copy/1.txt");

		boolean append = false;
		try {
			FileChannel wChannel = new FileOutputStream(file, append).getChannel();
			wChannel.write(bbuf);
			wChannel.close();
			System.out.println("将 ByteBuffer 追加到文件成功");
		} catch (IOException e) {
		}
	}
}
